package flexo.physic.force;

import flexo.math.Vector;
import flexo.physic.entity.Entity;

public class Drag extends Force
{
	protected Vector force;
	
	protected float k1,k2;

	public Drag(String name, float k1, float k2)
	{
		super(name);
		force = new Vector();
		this.k1 = k1;
		this.k2 = k2;
	}

	@Override
	public Vector calculateForce(Entity e, float deltaTime)
	{
		force.set(e.getVelocity());
		force.negate();
		
		float mag = force.getLength();
		
		float drag = 0;
		drag += k1 * mag;
		drag += k2 * mag * mag;
		
		force.scale(drag);
		
		return force;
	}

}
